<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SunCMS 后台管理系统</title>
<link href="./images/system/style.css" rel="stylesheet" type="text/css">
<script src="./include/javascript/jquery.js" type="text/javascript"></script>
<script src="./include/javascript/main.js" type="text/javascript"></script>
<script type="text/javascript">
	var SCRIPT='<?php echo SCRIPT_NAME?>';
	var SITE_URL='<?php echo SITE_URL?>';

	var catMove = {
		frame: <?php echo $frame; ?>,
		save: function()
		{
			var catid = $("#catid").val();
			var moveid = $("#moveid").val();
			if(moveid=='')
			{
				parent.dialog.alert('请选择要转移到的栏目！');
				return false;
			}
			else if(catid==$("#cat_menu #cat_"+moveid).attr('pid'))
			{
				parent.dialog.alert('不允许将栏目转移到该栏目的子栏目下！');
				return false;
			}
			var path = $("#path").val();
			var pid = $("#pid").val();
			$.ajax({
				url: SITE_URL+SCRIPT+"?m=document&a=category&do=movecategory",
				data:{'catid':catid,'moveid':moveid,'path':path,'pid':pid},
				error: function (xmlHttpRequest, error) {
					parent.dialog.alert('AJAX数据获取异常！');
				},
				success: function(rs)
				{
					parent.dialog.alert('success!',1);
				}
			});
		},
		treeClick: function(catid)
		{
			var currCatId =  $("#moveid").val();
			if(currCatId==catid) return false;
			$("#cat_menu .tree_item").removeClass("tree_active");
			$("#cat_menu #cat_"+catid).addClass("tree_active");
			$("#moveid").val(catid);
			$("#cat_menu #cat_"+catid+" :radio").attr('checked','true');
		},
		getCategoryMenu: function()
		{
			/** todo: 获取栏目树 **/
			var model = $("#model").val();
			$.ajax({
				url: SITE_URL+SCRIPT+"?m=document&a=category&do=getcategory",
				data:{'model':model},
				error: function (xmlHttpRequest, error) {
					parent.dialog.alert('AJAX数据获取异常！');
				},
				success: function(rs)
				{
					$("#cat_menu").empty();
					var html = '';
					for(i in rs)
					{
						if(rs[i].onepage==0)
						{
							var treeStyle=rs[i].level>2?'none':'block';
							html+='<div class="tree_item style="display:'+treeStyle+'" id="cat_'+rs[i].id+'" pid="'+rs[i].pid+'" onclick="catMove.treeClick('+rs[i].id+')" ';
							html+='>'+rs[i].img+'<input type="radio" name="moveid" value="'+rs[i].id+'" onclick="catMove.treeClick('+rs[i].id+');">'+rs[i].name+'</div>';
						}
					}
					$("#cat_menu").html(html);
				}
			});
		}
	}
</script>
</head>
<body>
<div class="main">
<div class='main_left'>
<div class='main_right'>

<input type='hidden' id='catid' value='<?php echo $catid; ?>'>
<input type='hidden' id='path' value='<?php echo $datas['path']; ?>'>
<input type='hidden' id='pid' value='<?php echo $datas['pid']; ?>'>
<input type='hidden' id='moveid' value=''>

<div style='padding:10px 0 5px 5px;'>
	文档模型：<select id='model' onchange='catMove.getCategoryMenu();' style='height:18px; width:75px;' <?php if($datas['child']==1||$datas['document_no']>0||$datas['pid']!=0)echo "disabled"; ?>>
		<option value='article'>&nbsp;&nbsp;文章
		<option value='picture'>&nbsp;&nbsp;图片
		<option value='video'>&nbsp;&nbsp;视频
		<option value='download'>&nbsp;&nbsp;下载
		<option value='product'>&nbsp;&nbsp;产品
	</select>
</div>
<div id='cat_menu' style='height:360px;width:460px;'>
	<?php foreach( $tree as $v ){ if($v['onepage']==0){?>
	<div class="tree_item" id="cat_<?php echo $v['id']; ?>" pid="<?php echo $v['pid'].'" '; if($v['level']>2){ ?> style='display:none;' <?php } ?>onclick="catMove.treeClick(<?php echo $v['id']; ?>);"<?php echo '>'.$v['img'].'<input type="radio" name="moveid" value="'.$v['id'].'" onclick="catMove.treeClick('.$v["id"].');">'.$v['name']; ?></div>
	<?php } }?>
</div>

<input type='button' onclick='catMove.save();' id='sbt' style='display:none;'>

</div><!--/main_right-->
</div><!--/main_left-->
</div><!--/main-->
</body>
</html>